package com.hawk.config;

import com.hawk.domain.LogDomain;
import com.hawk.parse.LogPrintService;
import com.hawk.parse.LogUserService;
import com.hawk.utils.SpringContextUtil;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

/**
 * @author hawk
 * @date 2022/1/10 15:15
 * @desc
 **/
@Configuration
@ComponentScan("com.hawk")
public class LogConfiguration {

    @Bean
    @ConditionalOnMissingBean(LogPrintService.class)
    public LogPrintService logPrintService() {
        return new LogPrintService() {
            @Override
            public void print(LogDomain logDomain) {
                LogPrintService.super.print(logDomain);
            }
        };
    }

    @Bean
    @ConditionalOnMissingBean(LogUserService.class)
    public LogUserService logUserService() {
        return new LogUserService() {
            @Override
            public String getUser() {
                return LogUserService.super.getUser();
            }
        };
    }


    @Bean
    public SpringContextUtil springContextUtil() {
        return new SpringContextUtil();
    }


}
